<!DOCTYPE html>

































































<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link rel="shortcut icon" type="image/x-icon" href="../../../favicon.ico" />
<title>Tasks and Back Stack | Android Developers</title>
<link href="../../../assets/android-developer-docs-devguide.css" rel="stylesheet" type="text/css" />
<script src="../../../assets/search_autocomplete.js" type="text/javascript"></script>
<script src="../../../assets/jquery-resizable.min.js" type="text/javascript"></script>
<script src="../../../assets/android-developer-docs.js" type="text/javascript"></script>
<script src="../../../assets/prettify.js" type="text/javascript"></script>
<script type="text/javascript">
  setToRoot("../../../");
</script>
<noscript>
  <style type="text/css">
    html,body{overflow:auto;}
    #body-content{position:relative; top:0;}
    #doc-content{overflow:visible;border-left:3px solid #666;}
    #side-nav{padding:0;}
    #side-nav .toggle-list ul {display:block;}
    #resize-packages-nav{border-bottom:3px solid #666;}
  </style>
</noscript>
</head>
<body class="gc-documentation">

  <div id="header">
      <div id="headerLeft">
          <a href="../../../index.html" tabindex="-1"><img
              src="../../../assets/images/bg_logo.png" alt="Android Developers" /></a>
          <ul id="header-tabs" class="guide">
    
	<li id="home-link"><a href="../../../offline.html">
	
		<span class="en">Home</span>
		<span style="display:none" class="de">Startseite</span>
		<span style="display:none" class="es"></span>
		<span style="display:none" class="fr"></span>
		<span style="display:none" class="it"></span>
		<span style="display:none" class="ja">ホーム</span>
		<span style="display:none" class="zh-CN">主页</span>
		<span style="display:none" class="zh-TW">首頁</span>
	
	</a></li>
	<li id="sdk-link"><a href="../../../sdk/index.html">
		<span class="en">SDK</span>
	</a></li>
	<li id="guide-link"><a href="../../../guide/index.html" onClick="return loadLast('guide')">
	
		<span class="en">Dev Guide</span>
		<span style="display:none" class="de">Handbuch</span>
		<span style="display:none" class="es">Guía</span>
		<span style="display:none" class="fr">Guide</span>
		<span style="display:none" class="it">Guida</span>
		<span style="display:none" class="ja">開発ガイド</span>
		<span style="display:none" class="zh-CN">开发人员指南</span>
		<span style="display:none" class="zh-TW">開發指南</span>
	
	</a></li>
	<li id="reference-link"><a href="../../../reference/packages.html" onClick="return loadLast('reference')">
	
		<span class="en">Reference</span>
		<span style="display:none" class="de">Referenz</span>
		<span style="display:none" class="es">Referencia</span>
		<span style="display:none" class="fr">Référence</span>
		<span style="display:none" class="it">Riferimento</span>
		<span style="display:none" class="ja">リファレンス</span>
		<span style="display:none" class="zh-CN">参考</span>
		<span style="display:none" class="zh-TW">參考資料</span>
	
	</a></li>
	<li id="resources-link"><a href="../../../resources/index.html" onClick="return loadLast('resources')">
	
		<span class="en">Resources</span>
		<span style="display:none" class="de"></span>
		<span style="display:none" class="es"></span>
		<span style="display:none" class="fr"></span>
		<span style="display:none" class="it"></span>
    		<span style="display:none" class="ja"></span>
		<span style="display:none" class="zh-CN"></span>
		<span style="display:none" class="zh-TW"></span>
	
	</a></li>
	<li id="videos-link"><a href="../../../videos/index.html" onClick="return loadLast('videos')">
	
		<span class="en">Videos</span>
		<span style="display:none" class="de"></span>
		<span style="display:none" class="es"></span>
		<span style="display:none" class="fr"></span>
		<span style="display:none" class="it"></span>
		<span style="display:none" class="ja">ビデオ</span>
		<span style="display:none" class="zh-CN"></span>
		<span style="display:none" class="zh-TW"></span>
	
	</a></li>
	<li><a href="http://android-developers.blogspot.com" onClick="return requestAppendHL(this.href)">
	
		<span class="en">Blog</span>
		<span style="display:none" class="de"></span>
		<span style="display:none" class="es"></span>
		<span style="display:none" class="fr"></span>
		<span style="display:none" class="it"></span>
		<span style="display:none" class="ja">ブログ</span>
		<span style="display:none" class="zh-CN">博客</span>
		<span style="display:none" class="zh-TW">網誌</span>
	
	</a></li>


     
</ul>
     
      </div>
      <div id="headerRight">
          <div id="headerLinks">
          
          <a href="http://www.android.com">Android.com</a>
          </div>
  <div id="search" >
      <div id="searchForm">
          <form accept-charset="utf-8" class="gsc-search-box" 
                onsubmit="return submit_search()">
            <table class="gsc-search-box" cellpadding="0" cellspacing="0"><tbody>
                <tr>
                  <td class="gsc-input">
                    <input id="search_autocomplete" class="gsc-input" type="text" size="33" autocomplete="off"
                      title="search developer docs" name="q"
                      value="search developer docs"
                      onFocus="search_focus_changed(this, true)"
                      onBlur="search_focus_changed(this, false)"
                      onkeydown="return search_changed(event, true, '../../../')"
                      onkeyup="return search_changed(event, false, '../../../')" />
                  <div id="search_filtered_div" class="no-display">
                      <table id="search_filtered" cellspacing=0>
                      </table>
                  </div>
                  </td>
                  <td class="gsc-search-button">
                    <input type="submit" value="Search" title="search" id="search-button" class="gsc-search-button" />
                  </td>
                  <td class="gsc-clear-button">
                    <div title="clear results" class="gsc-clear-button">&nbsp;</div>
                  </td>
                </tr></tbody>
              </table>
          </form>
      </div><!-- searchForm -->
  </div><!-- search -->
      </div><!-- headerRight -->
      <script type="text/javascript">
        <!--  
        changeTabLang(getLangPref());
        //-->
      </script>
  </div><!-- header -->

  <div class="g-section g-tpl-240" id="body-content">
    <div class="g-unit g-first" id="side-nav">
      <div id="devdoc-nav">
<ul>

  <li>
    <h2><span class="en">Android Basics</span>
        <span class="de" style="display:none">Einführung in Android</span>
        <span class="es" style="display:none">Información básica sobre Android</span>
        <span class="fr" style="display:none">Présentation d'Android</span>
        <span class="it" style="display:none">Nozioni di base su Android</span>
        <span class="ja" style="display:none">Android の基本</span>
        <span class="zh-CN" style="display:none">Android 基础知识</span>
        <span class="zh-TW" style="display:none">Android 簡介</span>
    </h2>
    <ul>
      <li><a href="../../../guide/basics/what-is-android.html">
        <span class="en">What Is Android?</span>
        <span class="de" style="display:none">Was ist Android?</span>
        <span class="es" style="display:none">¿Qué es Android?</span>
        <span class="fr" style="display:none">Qu'est-ce qu'Android&nbsp;?</span>
        <span class="it" style="display:none">Che cos'è Android?</span>
        <span class="ja" style="display:none">Android とは</span>
        <span class="zh-CN" style="display:none">Android 是什么？</span>
        <span class="zh-TW" style="display:none">什麼是 Android？</span>
          </a></li>
      <li><a href="../../../guide/topics/fundamentals.html">
        <span class="en">Application Fundamentals</span>
        <span class="de" style="display:none">Anwendungsgrundlagen</span>
        <span class="es" style="display:none">Fundamentos de las aplicaciones</span>
        <span class="fr" style="display:none">Principes de base des applications</span>
        <span class="it" style="display:none">Concetti fondamentali sulle applicazioni</span>
        <span class="ja" style="display:none">開発の基礎</span>
        <span class="zh-CN" style="display:none">应用程序基础</span>
        <span class="zh-TW" style="display:none">應用程式基本原理</span>
      </a></li>

  <!--  <li><a style="color:gray;">The Android SDK</a></li> -->
  <!--  <li><a style="color:gray;">Walkthrough for Developers</a></li> -->
      <!-- quick overview of what it's like to develop on Android -->
    </ul>
  </li>

  <li>
    <h2>
      <span class="en">Framework Topics</span>
      <span class="de" style="display:none">Framework-Themen</span>
      <span class="es" style="display:none">Temas sobre el framework</span>
      <span class="fr" style="display:none">Thèmes relatifs au framework</span>
      <span class="it" style="display:none">Argomenti relativi al framework</span>
      <span class="ja" style="display:none">フレームワーク トピック</span>
      <span class="zh-CN" style="display:none">框架主题</span>
      <span class="zh-TW" style="display:none">架構主題</span>
    </h2>
    <ul>
      <li class="toggle-list">
        <div><a href="../../../guide/topics/fundamentals/activities.html">
          <span class="en">Activities</span>
        </a></div>
        <ul>
          <li><a href="../../../guide/topics/fundamentals/fragments.html">
            <span class="en">Fragments</span>
          </a></li>
          <li><a href="../../../guide/topics/fundamentals/loaders.html">
            <span class="en">Loaders</span>
          </a></li>
          <li><a href="../../../guide/topics/fundamentals/tasks-and-back-stack.html">
            <span class="en">Tasks and Back Stack</span></a></li>
        </ul>
      </li>
      <li class="toggle-list">
        <div><a href="../../../guide/topics/fundamentals/services.html">
          <span class="en">Services</span>
        </a></div>
        <ul>
          <li><a href="../../../guide/topics/fundamentals/bound-services.html">
            <span class="en">Bound Services</span>
          </a></li>
        </ul>
      </li>
      <li><a href="../../../guide/topics/providers/content-providers.html">
            <span class="en">Content Providers</span>
          </a></li>
      <li><a href="../../../guide/topics/intents/intents-filters.html">
            <span class="en">Intents and Intent Filters</span>
          </a></li>
      <li><a href="../../../guide/topics/fundamentals/processes-and-threads.html">
            <span class="en">Processes and Threads</span>
          </a></li>
    </ul>


    <ul>
      <li class="toggle-list">
        <div><a href="../../../guide/topics/ui/index.html">
            <span class="en">User Interface</span>
          </a></div>
        <ul>
          <li><a href="../../../guide/topics/ui/declaring-layout.html">
               <span class="en">XML Layouts</span>
              </a></li>
          <li><a href="../../../guide/topics/ui/ui-events.html">
                <span class="en">Input Events</span>
              </a></li>
          <li><a href="../../../guide/topics/ui/menus.html">
               <span class="en">Menus</span>
              </a></li>
          <li><a href="../../../guide/topics/ui/actionbar.html">
               <span class="en">Action Bar</span>
              </a></li>
          <li><a href="../../../guide/topics/ui/dialogs.html">
                <span class="en">Dialogs</span>
              </a></li>
          <li class="toggle-list">
            <div><a href="../../../guide/topics/ui/notifiers/index.html">
                <span class="en">Notifications</span>
            </a></div>
            <ul>
              <li><a href="../../../guide/topics/ui/notifiers/toasts.html">
                <span class="en">Toast Notifications</span>
              </a></li>
              <li><a href="../../../guide/topics/ui/notifiers/notifications.html">
                <span class="en">Status Bar Notifications</span>
              </a></li>
            </ul>
          </li>
          <li><a href="../../../guide/topics/ui/drag-drop.html">
                <span class="en">Drag and Drop</span>
              </a></li>
          <li><a href="../../../guide/topics/ui/themes.html">
                <span class="en">Styles and Themes</span>
              </a></li>
          <li><a href="../../../guide/topics/ui/custom-components.html">
                <span class="en">Custom Components</span>
              </a></li>
          <li><a href="../../../guide/topics/ui/binding.html">
                <span class="en">Binding to Data with AdapterView</span>
              </a></li>
          <li><a href="../../../guide/topics/ui/layout-objects.html">
                <span class="en">Common Layout Objects</span>
              </a></li>
          <li><a href="../../../guide/topics/ui/how-android-draws.html">
                <span class="en">How Android Draws Views</span>
              </a></li>
        </ul>
      </li><!-- end of User Interface -->

      <li class="toggle-list">
        <div><a href="../../../guide/topics/resources/index.html">
               <span class="en">Application Resources</span>
             </a></div>
        <ul>
          <li><a href="../../../guide/topics/resources/providing-resources.html">
                <span class="en">Providing Resources</span>
              </a></li>
          <li><a href="../../../guide/topics/resources/accessing-resources.html">
                <span class="en">Accessing Resources</span>
              </a></li>
          <li><a href="../../../guide/topics/resources/runtime-changes.html">
                <span class="en">Handling Runtime Changes</span>
              </a></li>
          <li><a href="../../../guide/topics/resources/localization.html">
                <span class="en">Localization</span>
              </a></li>
          <li class="toggle-list">
            <div><a href="../../../guide/topics/resources/available-resources.html">
              <span class="en">Resource Types</span>
            </a></div>
            <ul>
              <li><a href="../../../guide/topics/resources/animation-resource.html">Animation</a></li>
              <li><a href="../../../guide/topics/resources/color-list-resource.html">Color State List</a></li>
              <li><a href="../../../guide/topics/resources/drawable-resource.html">Drawable</a></li>
              <li><a href="../../../guide/topics/resources/layout-resource.html">Layout</a></li>
              <li><a href="../../../guide/topics/resources/menu-resource.html">Menu</a></li>
              <li><a href="../../../guide/topics/resources/string-resource.html">String</a></li>
              <li><a href="../../../guide/topics/resources/style-resource.html">Style</a></li>
              <li><a href="../../../guide/topics/resources/more-resources.html">More Types</a></li>
            </ul>
          </li><!-- end of resource types -->
        </ul>
      </li><!-- end of app resources -->
      <li class="toggle-list">
        <div><a href="../../../guide/topics/data/data-storage.html">
            <span class="en">Data Storage</span>
          </a></div>
          <ul>
            <li><a href="../../../guide/topics/data/backup.html">
                <span class="en">Data Backup</span>
              </a>
            </li>
          </ul>
      </li>
      <li><a href="../../../guide/topics/security/security.html">
            <span class="en">Security and Permissions</span>
          </a></li>
      <li class="toggle-list">
        <div><a href="../../../guide/topics/manifest/manifest-intro.html">
          <span class="en">The AndroidManifest.xml File</span>
        </a></div>
        <ul>
          <li><a href="../../../guide/topics/manifest/action-element.html">&lt;action&gt;</a></li>
          <li><a href="../../../guide/topics/manifest/activity-element.html">&lt;activity&gt;</a></li>
          <li><a href="../../../guide/topics/manifest/activity-alias-element.html">&lt;activity-alias&gt;</a></li>
          <li><a href="../../../guide/topics/manifest/application-element.html">&lt;application&gt;</a></li>
          <li><a href="../../../guide/topics/manifest/category-element.html">&lt;category&gt;</a></li>
          <li><a href="../../../guide/topics/manifest/compatible-screens-element.html">&lt;compatible-screens&gt;</a></li>
          <li><a href="../../../guide/topics/manifest/data-element.html">&lt;data&gt;</a></li>
          <li><a href="../../../guide/topics/manifest/grant-uri-permission-element.html">&lt;grant-uri-permission&gt;</a></li>
          <li><a href="../../../guide/topics/manifest/instrumentation-element.html">&lt;instrumentation&gt;</a></li>
          <li><a href="../../../guide/topics/manifest/intent-filter-element.html">&lt;intent-filter&gt;</a></li>
          <li><a href="../../../guide/topics/manifest/manifest-element.html">&lt;manifest&gt;</a></li>
          <li><a href="../../../guide/topics/manifest/meta-data-element.html">&lt;meta-data&gt;</a></li>
          <li><a href="../../../guide/topics/manifest/path-permission-element.html">&lt;path-permission&gt;</a></li>
          <li><a href="../../../guide/topics/manifest/permission-element.html">&lt;permission&gt;</a></li>
          <li><a href="../../../guide/topics/manifest/permission-group-element.html">&lt;permission-group&gt;</a></li>
          <li><a href="../../../guide/topics/manifest/permission-tree-element.html">&lt;permission-tree&gt;</a></li>
          <li><a href="../../../guide/topics/manifest/provider-element.html">&lt;provider&gt;</a></li>
          <li><a href="../../../guide/topics/manifest/receiver-element.html">&lt;receiver&gt;</a></li>
          <li><a href="../../../guide/topics/manifest/service-element.html">&lt;service&gt;</a></li>
          <li><a href="../../../guide/topics/manifest/supports-gl-texture-element.html">&lt;supports-gl-texture&gt;</a></li>
          <li><a href="../../../guide/topics/manifest/supports-screens-element.html">&lt;supports-screens&gt;</a></li><!-- ##api level 4## -->
          <li><a href="../../../guide/topics/manifest/uses-configuration-element.html">&lt;uses-configuration&gt;</a></li>
          <li><a href="../../../guide/topics/manifest/uses-feature-element.html">&lt;uses-feature&gt;</a></li> <!-- ##api level 4## -->
          <li><a href="../../../guide/topics/manifest/uses-library-element.html">&lt;uses-library&gt;</a></li>
          <li><a href="../../../guide/topics/manifest/uses-permission-element.html">&lt;uses-permission&gt;</a></li>
          <li><a href="../../../guide/topics/manifest/uses-sdk-element.html">&lt;uses-sdk&gt;</a></li>
        </ul>
      </li><!-- end of the manifest file -->
    </ul>

    <ul>
    <li class="toggle-list">
        <div><a href="../../../guide/topics/graphics/index.html">
            <span class="en">Graphics</span>
          </a><span class="new-child">new!</span></div>
        <ul>
          <li><a href="../../../guide/topics/graphics/2d-graphics.html">
              <span class="en">Canvas and Drawables</span></a></li>
          <li><a href="../../../guide/topics/graphics/hardware-accel.html">
              <span class="en">Hardware Acceleration</span></a>
            <span class="new">new!</span></li>
          <li><a href="../../../guide/topics/graphics/opengl.html">
              <span class="en">OpenGL</span>
            </a><span class="new">updated</span></li>
        </ul>
      </li>
      <li class="toggle-list">
        <div><a href="../../../guide/topics/graphics/animation.html">
            <span class="en">Animation</span>
          </a></div>
        <ul>
          <li><a href="../../../guide/topics/graphics/prop-animation.html">
              <span class="en">Property Animation</span></a></li>
          <li><a href="../../../guide/topics/graphics/view-animation.html">
              <span class="en">View Animation</span></a></li>
          <li><a href="../../../guide/topics/graphics/drawable-animation.html">
              <span class="en">Drawable Animation</span></a></li>
        </ul>
      </li>
      <li class="toggle-list">
	        <div><a href="../../../guide/topics/renderscript/index.html">
	            <span class="en">RenderScript</span>
	          </a></div>
	        <ul>
	          <li><a href="../../../guide/topics/renderscript/graphics.html">
	                <span class="en">Graphics</span>
	              </a>
	          </li>
	          <li><a href="../../../guide/topics/renderscript/compute.html">
	                <span class="en">Compute</span>
	              </a>
	          </li>
	        </ul>
  	  </li>

      <li class="toggle-list">
          <div><a href="../../../guide/topics/media/index.html">
            <span class="en">Multimedia and Camera</span>
          </a><span class="new">updated</span></div>
          <ul>
            <li><a href="../../../guide/topics/media/mediaplayer.html">
                  <span class="en">Media Playback</span></a>
                </li>
            <li><a href="../../../guide/topics/media/jetplayer.html">
                  <span class="en">JetPlayer</span></a>
                </li>
            <li><a href="../../../guide/topics/media/camera.html">
                  <span class="en">Camera</span></a>
                  <span class="new">new!</span>
                </li>
            <li><a href="../../../guide/topics/media/audio-capture.html">
                  <span class="en">Audio Capture</span></a>
                </li>
          </ul>
      </li>
      <li>
        <a href="../../../guide/topics/clipboard/copy-paste.html">
            <span class="en">Copy and Paste</span>
        </a></li>
  <!--<li class="toggle-list">
        <div><a style="color:gray;">Sensors</a></div>
          <ul>
            <li><a style="color:gray;">Camera</a></li>
            <li><a style="color:gray;">Compass</a></li>
            <li><a style="color:gray;">Accelerometer</a></li>
          </ul>
      </li> -->
      <li class="toggle-list">
        <div><a href="../../../guide/topics/location/index.html">
               <span class="en">Location and Maps</span>
             </a></div>
        <ul>
          <li><a href="../../../guide/topics/location/obtaining-user-location.html">
                <span class="en">Obtaining User Location</span>
              </a></li>
        </ul>
      </li>
  <!--<li class="toggle-list">
        <div><a style="color:gray;">Wireless Controls</a></div>
          <ul>
            <li><a style="color:gray;">Wi-Fi</a></li>
          </ul>
      </li> -->
  <!--<li><a style="color:gray;">Localization</a></li>  -->
      <li><a href="../../../guide/topics/appwidgets/index.html">
            <span class="en">App Widgets</span></a>
          </li>
      <li><a href="../../../guide/topics/wireless/bluetooth.html">
            <span class="en">Bluetooth</span></a>
          </li>
      <li><a href="../../../guide/topics/nfc/index.html">
            <span class="en">Near Field Communication</span>
          </a></li>
      <li class="toggle-list">
          <div><a href="../../../guide/topics/usb/index.html">
            <span class="en">USB</span></a>
          </div>
            <ul>
              <li><a href="../../../guide/topics/usb/accessory.html">Accessory</a></li>
              <li><a href="../../../guide/topics/usb/host.html">Host</a></li>
              <li><a href="../../../guide/topics/usb/adk.html">Open Accessory Dev Kit</a></li>
            </ul>
          </li>

       <li><a href="../../../guide/topics/network/sip.html">
            <span class="en">Session Initiation Protocol</span>
          </a></li>
      <li class="toggle-list">
        <div><a href="../../../guide/topics/search/index.html">
            <span class="en">Search</span>
          </a></div>
          <ul>
            <li><a href="../../../guide/topics/search/search-dialog.html">Creating a Search Interface</a></li>
            <li><a href="../../../guide/topics/search/adding-recent-query-suggestions.html">Adding Recent Query Suggestions</a></li>
            <li><a href="../../../guide/topics/search/adding-custom-suggestions.html">Adding Custom Suggestions</a></li>
            <li><a href="../../../guide/topics/search/searchable-config.html">Searchable Configuration</a></li>
          </ul>
      </li>
      <li><a href="../../../guide/topics/admin/device-admin.html">
            <span class="en">Device Administration</span></a>
      </li>
      <li class="toggle-list">
           <div>
                <a href="../../../guide/topics/testing/index.html">
                   <span class="en">Testing</span>
               </a>
           </div>
           <ul>
              <li>
                <a href="../../../guide/topics/testing/testing_android.html">
                <span class="en">Testing Fundamentals</span></a>
              </li>
              <li>
                <a href="../../../guide/topics/testing/activity_testing.html">
                <span class="en">Activity Testing</span></a>
              </li>
              <li>
                <a href="../../../guide/topics/testing/contentprovider_testing.html">
                <span class="en">Content Provider Testing</span></a>
              </li>
              <li>
                <a href="../../../guide/topics/testing/service_testing.html">
                <span class="en">Service Testing</span></a>
              </li>
              <li>
                <a href="../../../guide/topics/testing/what_to_test.html">
                <span class="en">What To Test</span></a>
              </li>
           </ul>
      </li>
    </ul>
  </li>

  <li>
    <h2>
      <span class="en">Android Market Topics</span>
    </h2>
    <ul>
      <li><a href="../../../guide/publishing/licensing.html">
          <span class="en">Application Licensing</span></a>
      </li>
      <li class="toggle-list">
        <div><a href="../../../guide/market/billing/index.html">
            <span class="en">In-app Billing</span></a>
        </div>
        <ul>
          <li><a href="../../../guide/market/billing/billing_overview.html">
              <span class="en">In-app Billing Overview</span></a>
          </li>
          <li><a href="../../../guide/market/billing/billing_integrate.html">
              <span class="en">Implementing In-app Billing</span></a>
          </li>
          <li><a href="../../../guide/market/billing/billing_best_practices.html">
              <span class="en">Security and Design</span></a>
          </li>
          <li><a href="../../../guide/market/billing/billing_testing.html">
              <span class="en">Testing In-app Billing</span></a>
          </li>
          <li><a href="../../../guide/market/billing/billing_admin.html">
              <span class="en">Administering In-app Billing</span></a>
          </li>
          <li><a href="../../../guide/market/billing/billing_reference.html">
              <span class="en">In-app Billing Reference</span></a>
          </li>
        </ul>
      </li>
      <li><a href="../../../guide/appendix/market-filters.html">
          <span class="en">Market Filters</span></a>
      </li>
      <li><a href="../../../guide/market/publishing/multiple-apks.html">
          <span class="en">Multiple APK Support</span></a>
      </li>
    </ul>
  </li>


  <li>
    <h2><span class="en">Developing</span>
               <span class="de" style="display:none">Entwicklung</span>
               <span class="es" style="display:none">Desarrollo</span>
               <span class="fr" style="display:none">Développement</span>
               <span class="it" style="display:none">Sviluppo</span>
               <span class="ja" style="display:none">開発</span>
               <span class="zh-CN" style="display:none">开发</span>
               <span class="zh-TW" style="display:none">開發</span>
    </h2>
    <ul>
  <!--<li><a href="">Developing for Android</a></li>
      signing, upgrading, selecting a package name, select device profile, touch, trackball, dpad available, etc. -->
      <li>
        <a href="../../../guide/developing/index.html">
        <span class="en">Introduction</span></a>
      </li>

      <li class="toggle-list">
        <div>
           <a href="../../../guide/developing/devices/index.html">
                <span class="en">Managing Virtual Devices</span>
            </a>
        </div>
        <ul>
          <li>
            <a href="../../../guide/developing/devices/managing-avds.html">
              <span class="en">With AVD Manager</span>
            </a>
          </li>
          <li>
            <a href="../../../guide/developing/devices/managing-avds-cmdline.html">
              <span class="en">From the Command Line</span>
            </a>
          </li>
          <li>
           <a href="../../../guide/developing/devices/emulator.html">
                <span class="en">Using the Android Emulator</span>
            </a>
          </li>
        </ul>
      </li>
      <li>
        <a href="../../../guide/developing/device.html">
          <span class="en">Using Hardware Devices</span>
        </a>
      </li>

      <li class="toggle-list">
        <div>
          <a href="../../../guide/developing/projects/index.html">
            <span class="en">Managing Projects</span>
          </a>
        </div>
        <ul>
          <li>
            <a href="../../../guide/developing/projects/projects-eclipse.html">
              <span class="en">From Eclipse with ADT</span>
            </a>
          </li>
          <li>
            <a href="../../../guide/developing/projects/projects-cmdline.html">
                <span class="en">From the Command Line</span>
            </a>
          </li>
        </ul>
      </li>

      <li class="toggle-list">
        <div>
          <a href="../../../guide/developing/building/index.html">
            <span class="en">Building and Running</span>
          </a>
        </div>
        <ul>
          <li><a href="../../../guide/developing/building/building-eclipse.html">
            <span class="en">From Eclipse with ADT</span>
          </a></li>
          <li><a href="../../../guide/developing/building/building-cmdline.html">
            <span class="en">From the Command Line</span></a></li>
        </ul>
      </li>

      <li class="toggle-list">
        <div>
          <a href="../../../guide/developing/debugging/index.html">
            <span class="en">Debugging</span>
          </a>
        </div>
        <ul>
          <li>
            <a href="../../../guide/developing/debugging/debugging-projects.html">
                <span class="en">From Eclipse with ADT</span>
            </a>
          </li>
          <li>
            <a href="../../../guide/developing/debugging/debugging-projects-cmdline.html">
                <span class="en">From Other IDEs</span>
            </a>
          </li>
          <li>
            <a href="../../../guide/developing/debugging/ddms.html">
              <span class="en">Using DDMS</span>
            </a>
          </li>
          <li>
            <a href="../../../guide/developing/debugging/debugging-log.html">
                <span class="en">Reading and Writing Logs</span>
            </a>
          </li>
          <li>
            <a href="../../../guide/developing/debugging/debugging-ui.html">
                <span class="en">Debugging and Profiling UIs</span>
            </a>
          </li>
          <li>
            <a href="../../../guide/developing/debugging/debugging-tracing.html">
                <span class="en">Profiling with Traceview and dmtracedump</span>
            </a>
          </li>
          <li>
            <a href="../../../guide/developing/debugging/debugging-devtools.html">
                <span class="en">Using the Dev Tools App</span>
            </a>
          </li>
        </ul>
      </li>

      <li class="toggle-list">
           <div>
                <a href="../../../guide/developing/testing/index.html">
                   <span class="en">Testing</span>
               </a>
           </div>
           <ul>
              <li>
                <a href="../../../guide/developing/testing/testing_eclipse.html">
                  <span class="en">From Eclipse with ADT</span>
                </a>
              </li>

              <li>
                <a href="../../../guide/developing/testing/testing_otheride.html">
                  <span class="en">From Other IDEs</span>
                </a>
              </li>
           </ul>
         </li>

         <li class="toggle-list">
        <div><a href="../../../guide/developing/tools/index.html">
            <span class="en">Tools</span>
          </a></div>
        <ul>
          <li><a href="../../../guide/developing/tools/adb.html">adb</a></li>
          <li><a href="../../../guide/developing/tools/adt.html">ADT</a></li>
          <li><a href="../../../guide/developing/tools/android.html">android</a></li>
          <li><a href="../../../guide/developing/tools/bmgr.html">bmgr</a>
          <li><a href="../../../guide/developing/tools/dmtracedump.html">dmtracedump</a></li>
          <li><a href="../../../guide/developing/tools/draw9patch.html">Draw
          9-Patch</a></li>
          <li><a href="../../../guide/developing/tools/emulator.html">Emulator</a></li>
          <li><a href="../../../guide/developing/tools/etc1tool.html">etc1tool</a></li>
          <li><a href="../../../guide/developing/tools/hierarchy-viewer.html">Hierarchy Viewer</a></li>
          <li><a href="../../../guide/developing/tools/hprof-conv.html">hprof-conv</a></li>
          <li><a href="../../../guide/developing/tools/layoutopt.html">layoutopt</a></li>
          <li><a href="../../../guide/developing/tools/logcat.html">logcat</a></li>
          <li><a href="../../../guide/developing/tools/mksdcard.html">mksdcard</a></li>
          <li><a href="../../../guide/developing/tools/monkey.html">Monkey</a></li>
          <li class="toggle-list">
            <div><a href="../../../guide/developing/tools/monkeyrunner_concepts.html">
              <span class="en">monkeyrunner</span>
            </a></div>
            <ul>
              <li><a href="../../../guide/developing/tools/MonkeyDevice.html">
                <span class="en">MonkeyDevice</span>
                </a></li>
              <li><a href="../../../guide/developing/tools/MonkeyImage.html">
                <span class="en">MonkeyImage</span>
                </a></li>
              <li><a href="../../../guide/developing/tools/MonkeyRunner.html">
                <span class="en">MonkeyRunner</span>
                </a></li>
            </ul>
          </li>
          <li><a href="../../../guide/developing/tools/proguard.html">ProGuard</a></li>
          <li><a href="../../../guide/developing/tools/adb.html#sqlite">sqlite3</a></li>
          <li><a href="../../../guide/developing/tools/traceview.html">Traceview</a></li>
          <li><a href="../../../guide/developing/tools/zipalign.html">zipalign</a></li>
        </ul>
      </li>
    </ul>
  </li>

  <li>
    <h2><span class="en">Publishing</span>
        <span class="de" style="display:none">Veröffentlichung</span>
        <span class="es" style="display:none">Publicación</span>
        <span class="fr" style="display:none">Publication</span>
        <span class="it" style="display:none">Pubblicazione</span>
        <span class="ja" style="display:none">公開</span>
        <span class="zh-CN" style="display:none">发布</span>
        <span class="zh-TW" style="display:none">發佈</span>
    </h2>
    <ul>
      <li><a href="../../../guide/publishing/app-signing.html">
            <span class="en">Signing Your Applications</span>
            <span class="de" style="display:none">Signieren Ihrer Anwendungen</span>
            <span class="es" style="display:none">Firma de aplicaciones</span>
            <span class="fr" style="display:none">Attribution de votre signature <br />à vos applications</span>
            <span class="it" style="display:none">Firma delle applicazioni</span>
            <span class="ja" style="display:none">アプリケーションへの署名</span>
            <span class="zh-CN" style="display:none">应用程序签名</span>
            <span class="zh-TW" style="display:none">簽署應用程式</span>
          </a></li>
      <li><a href="../../../guide/publishing/versioning.html">
            <span class="en">Versioning Your Applications</span>
            <span class="de" style="display:none">Versionsverwaltung für Ihre <br />Anwendungen</span>
            <span class="es" style="display:none">Versiones de las aplicaciones</span>
            <span class="fr" style="display:none">Attribution d'une version à vos applications</span>
            <span class="it" style="display:none">Controllo versioni delle applicazioni</span>
            <span class="ja" style="display:none">アプリケーションのバージョニング</span>
            <span class="zh-CN" style="display:none">应用程序版本控制</span>
            <span class="zh-TW" style="display:none">應用程式版本設定</span>
          </a></li>
      <li><a href="../../../guide/publishing/preparing.html">
            <span class="en">Preparing to Publish</span>
            <span class="de" style="display:none">Vorbereitung auf die Veröffentlichung</span>
            <span class="es" style="display:none">Publicación de aplicaciones</span>
            <span class="fr" style="display:none">Préparation à la publication</span>
            <span class="it" style="display:none">Preparativi per la pubblicazione</span>
            <span class="ja" style="display:none">公開の準備</span>
            <span class="zh-CN" style="display:none">准备发布</span>
            <span class="zh-TW" style="display:none">準備發佈</span>
          </a></li>
      <li><a href="../../../guide/publishing/publishing.html">
            <span class="en">Publishing on Android Market</span>
          </a></li>
    </ul>
  </li>

  <li>
    <h2><span class="en">Best Practices</span>
               <span class="de" style="display:none">Bewährte Verfahren</span>
               <span class="es" style="display:none">Prácticas recomendadas</span>
               <span class="fr" style="display:none">Meilleures pratiques</span>
               <span class="it" style="display:none">Best practice</span>
               <span class="ja" style="display:none">ベスト プラクティス</span>
               <span class="zh-CN" style="display:none">最佳实践</span>
               <span class="zh-TW" style="display:none">最佳實務</span>
    </h2>
    <ul>
      <li><a href="../../../guide/practices/compatibility.html">
            <span class="en">Compatibility</span>
          </a></li>
      <li class="toggle-list">
        <div><a href="../../../guide/practices/screens_support.html">
          <span class="en">Supporting Multiple Screens</span>
        </a></div>
        <ul>
          <li><a href="../../../guide/practices/screens-distribution.html">
            <span class="en">Distributing to Specific Screens</span>
          </a></li>
          <li><a href="../../../guide/practices/screen-compat-mode.html">
            <span class="en">Screen Compatibility Mode</span>
          </a></li>
          <li><a href="../../../guide/practices/screens-support-1.5.html">
            <span class="en">Strategies for Android 1.5</span>
          </a></li>
        </ul>
      </li>
      <li><a href="../../../guide/practices/optimizing-for-3.0.html">
            <span class="en">Optimizing Apps for Android 3.0</span>
          </a></li>
      <li class="toggle-list">
        <div><a href="../../../guide/practices/ui_guidelines/index.html">
               <span class="en">UI Guidelines</span>
             </a></div>
        <ul>
          <li class="toggle-list">
            <div><a href="../../../guide/practices/ui_guidelines/icon_design.html">
                   <span class="en">Icon Design <span class="new">updated</span></span>
                 </a></div>
            <ul>
              <li><a href="../../../guide/practices/ui_guidelines/icon_design_launcher.html">
                    <span class="en">Launcher Icons <span class="new">updated</span></span>
                  </a></li>
              <li><a href="../../../guide/practices/ui_guidelines/icon_design_menu.html">
                    <span class="en">Menu Icons</span>
                  </a></li>
              <li><a href="../../../guide/practices/ui_guidelines/icon_design_action_bar.html">
                    <span class="en">Action Bar Icons <span class="new">new!</span></span>
                  </a></li>
              <li><a href="../../../guide/practices/ui_guidelines/icon_design_status_bar.html">
                    <span class="en">Status Bar Icons <span class="new">updated</span></span>
                  </a></li>
              <li><a href="../../../guide/practices/ui_guidelines/icon_design_tab.html">
                    <span class="en">Tab Icons</span>
                  </a></li>
              <li><a href="../../../guide/practices/ui_guidelines/icon_design_dialog.html">
                    <span class="en">Dialog Icons</span>
                  </a></li>
              <li><a href="../../../guide/practices/ui_guidelines/icon_design_list.html">
                    <span class="en">List View Icons</span>
                  </a></li>
            </ul>
          </li>
          <li><a href="../../../guide/practices/ui_guidelines/widget_design.html">
                <span class="en">App Widget Design <span class="new">updated</span></span>
              </a></li>
          <li><a href="../../../guide/practices/ui_guidelines/activity_task_design.html">
                <span class="en">Activity and Task Design</span>
              </a></li>
          <li><a href="../../../guide/practices/ui_guidelines/menu_design.html">
                <span class="en">Menu Design</span>
              </a></li>
        </ul>
      </li>
      </ul>
      <ul>
      <li><a href="../../../guide/practices/design/accessibility.html">
            <span class="en">Designing for Accessibility</span>
          </a></li>
      <li class="toggle-list">
        <div><a href="../../../guide/practices/design/performance.html">
            <span class="en">Designing for Performance</span>
          </a></div>
        <ul>
          <li><a href="../../../guide/practices/design/jni.html">
                <span class="en">JNI Tips</span>
              </a></li>
        </ul>
      </li>
      <li><a href="../../../guide/practices/design/responsiveness.html">
            <span class="en">Designing for Responsiveness</span>
          </a></li>
      <li><a href="../../../guide/practices/design/seamlessness.html">
            <span class="en">Designing for Seamlessness</span>
          </a></li>
    </ul>
  </li>

  <li>
    <h2><span class="en">Web Applications</span>
    </h2>
    <ul>
      <li><a href="../../../guide/webapps/index.html">
            <span class="en">Web Apps Overview</span>
          </a></li>
      <li><a href="../../../guide/webapps/targeting.html">
            <span class="en">Targeting Screens from Web Apps</span>
          </a></li>
      <li><a href="../../../guide/webapps/webview.html">
            <span class="en">Building Web Apps in WebView</span>
          </a></li>
      <li><a href="../../../guide/webapps/debugging.html">
            <span class="en">Debugging Web Apps</span>
          </a></li>
      <li><a href="../../../guide/webapps/best-practices.html">
            <span class="en">Best Practices for Web Apps</span>
          </a></li>
    </ul>
  </li>

  <li>
    <h2><span class="en">Appendix</span>
               <span class="de" style="display:none">Anhang</span>
               <span class="es" style="display:none">Apéndice</span>
               <span class="fr" style="display:none">Annexes</span>
               <span class="it" style="display:none">Appendice</span>
               <span class="ja" style="display:none">付録</span>
               <span class="zh-CN" style="display:none">附录</span>
               <span class="zh-TW" style="display:none">附錄</span>
    </h2>
    <ul>
      <li><a href="../../../guide/appendix/api-levels.html">
            <span class="en">Android API Levels</span>
          </a></li>
      <li><a href="../../../guide/appendix/install-location.html">
            <span class="en">App Install Location</span>
          </a></li>
      <li><a href="../../../guide/appendix/media-formats.html">
            <span class="en">Supported Media Formats <span class="new">updated</span></span>
          </a></li>
      <li><a href="../../../guide/appendix/g-app-intents.html">
            <span class="en">Intents List: Google Apps</span>
          </a></li>
      <li><a href="../../../guide/developing/tools/aidl.html">AIDL</a></li>
      <li><a href="../../../guide/appendix/glossary.html">
            <span class="en">Glossary</span>
          </a></li>
    </ul>
  </li>

</ul>

<script type="text/javascript">
<!--
    buildToggleLists();
    changeNavLang(getLangPref());
//-->
</script>

      </div>
    </div> <!-- end side-nav -->
    <script>
      addLoadEvent(function() {
        scrollIntoView("devdoc-nav");
        });
    </script>




<div class="g-unit" id="doc-content"><a name="top"></a>

<div id="jd-header" class="guide-header">
  <span class="crumb">
    
      <a href="activities.html">Activities</a> >
    
  </span>
<h1>Tasks and Back Stack</h1>
</div>

  <div id="jd-content">

    <div class="jd-descr">
    <div id="qv-wrapper">
<div id="qv">
<h2>Quickview</h2>
<ul>
  <li>All activities belong to a task</li>
  <li>A task contains a collection of activities in the order in which the user interacts with
them</li>
  <li>Tasks can move to the background and retain the state of each activity in order for users
to perform other tasks without losing their work</li>
</ul>

<h2>In this document</h2>
<ol>
<li><a href="#ActivityState">Saving Activity State</a></li></li>
<li><a href="#ManagingTasks">Managing Tasks</a>
  <ol>
    <li><a href="#TaskLaunchModes">Defining launch modes</a></li>
    <li><a href="#Affinities">Handling affinities</a></li>
    <li><a href="#Clearing">Clearing the back stack</a></li>
    <li><a href="#Starting">Starting a task</a></li>
  </ol>
</li>
</ol>

<h2>Articles</h2>
<ol>
  <li><a href="../../../resources/articles/multitasking-android-way.html">Multitasking the Android Way</a></li>
</ol>

<h2>See also</h2>
<ol>
  <li><a><a href="../../../videos/index.html#v=fL6gSd4ugSI">Application Lifecycle video</a></li>
  <li><a
href="../../../guide/topics/manifest/activity-element.html"><code>&lt;activity&gt;</code> manifest
element</a></li>
</ol>
</div>
</div>


<p>An application usually contains multiple <a
href="../../../guide/topics/fundamentals/activities.html">activities</a>. Each activity
should be designed around a specific kind of action the user can perform and can start other
activities. For example, an email application might have one activity to show a list of new email.
When the user selects an email, a new activity opens to view that email.</p>
<p>一个程序通常包含多个activity。每个activity都围绕着特别的行为或者启动其他activity而设计，一个邮件程序可能有一个新邮件列表的activity。当用户选择一个邮件，一个新的阅读邮件的activity会被打开。</p>

<p>An activity can even start activities that exist in other applications on the device. For
example, if your application wants to send an email, you can define an intent to perform a "send"
action and include some data, such as an email address and a message. An activity from another
application that declares itself to handle this kind of intent then opens. In this case, the intent
is to send an email, so an email application's "compose" activity starts (if multiple activities
support the same intent, then the system lets the user select which one to use). When the email is
sent, your activity resumes and it seems as if the email activity was part of your application. Even
though the activities may be from different applications, Android maintains this seamless user
experience by keeping both activities in the same <em>task</em>.</p>
<p>一个activity也可以启动其他程序里面的activity。例如，如果你的程序要发送email，你可以定义一个intent去执行发送任务，并包括邮件地址和邮件内容等数据。邮件程序的“compose”activity会启动，发送完成后返回自己程序的activity。尽管这些 Activity处于不同的应用， Android将这些 activity维护到同一个 task中给用户这种无缝的应用体验。 </p>

<p>A task is a collection of activities that users interact with
when performing a certain job. The activities are arranged in a stack (the "back stack"), in the
order in which each activity is opened.</p>
<p>一个 task是用户执行一个特定的工作与用户交互的一组特定的 Activity的集合。 Activity被安排到同一个栈 (back stack)中，其中的 activity按顺序的打开的。</p>

<!-- SAVE FOR WHEN THE FRAGMENT DOC IS ADDED
<div class="sidebox-wrapper">
<div class="sidebox">
<h3>Adding fragments to a task's back stack</h3>

<p>Your activity can also include <code><a href="../../../reference/android/app/Fragment.html">Fragment</a></code>s to the back stack. For example,
suppose you have a two-pane layout using fragments, one of which is a list view (fragment A) and the
other being a layout to display an item from the list (fragment B). When the user selects an item
from the list, fragment B is replaced by a new fragment (fragment C). In this case, it might be
desireable for the user to navigate back to reveal fragment B, using the BACK key.</p>
<p>In order to add fragment B to the back stack so that this is possible, you must call <code><a href="../../../reference/android/app/FragmentTransaction.html#addToBackStack(java.lang.String)">addToBackStack()</a></code> before you <code><a href="../../../reference/android/app/FragmentTransaction.html#commit()">commit()</a></code> the transaction that replaces fragment B with fragment
C.</p>
<p>For more information about using fragments and adding them to the back stack, see the <code><a href="../../../reference/android/app/Fragment.html">Fragment</a></code> class documentation.</p>

</div>
</div>
-->

<p>The device Home screen is the starting place for most tasks. When the user touches an icon in the
application
launcher (or a shortcut on the Home screen), that application's task comes to the foreground. If no
task exists for the application (the application has not been used recently), then a new task
is created and the "main" activity for that application opens as the root activity in the stack.</p>
<p>桌面是绝大多数任务被启动的地方。当用户在应用启动器中触击一个应用的图标，这个应用就会回到前台。如果没有这个应用的任务存在，那么创建一个新的 task,这个应用的 “main” Activity打开，并且作为这个 task栈的根 activity。</p>

<p>When the current activity starts another, the new activity is pushed on the top of the stack and
takes focus. The previous activity remains in the stack, but is stopped. When an activity
stops, the system retains the current state of its user interface. When the user presses the BACK
key, the current activity is popped from the top of the stack (the activity is destroyed) and the
previous activity resumes (the previous state of its UI is restored). Activities in the stack are
never rearranged, only pushed and popped from the stack&mdash;pushed onto the stack when started by
the current activity and popped off when the user leaves it using the BACK key. As such, the back
stack operates as a "last in, first out" object structure. Figure 1 visualizes
this behavior with a timeline showing the progress between activities along with the current back
stack at each point in time.</p>
<p>当当前 Activity启动另一个 Activity，新的 Activity被推到栈顶并且占据焦点。前一个 Activity保持在栈中，但是 处于 stop状态。当一个 activity停止掉后，系统保存他当前的用户接口的状态。当用户按 BACK键，当前的 Activity从栈中弹出并销毁，前一个 Activity被激活。栈中的 Actvity不会被重置，只会推入或者弹出。所以， back stack遵循一个"后进先出"的机制。</p>

<img src="../../../images/fundamentals/diagram_backstack.png" alt="" />
<p class="img-caption"><strong>Figure 1.</strong> A representation of how each new activity in a
task adds an item to the back stack. When the user presses the BACK key, the current activity is
destroyed and the previous activity resumes.</p>
<p></p>


<p>If the user continues to press BACK, then each activity in the stack is popped off to reveal the
previous one, until the user returns to the Home screen (or to whichever activity was running when
the task began). When all activities are removed from the stack, the task no longer exists.</p>
<p>如果用户继续按 BACK键，栈中的每个 Activity都从栈中弹出显示前一个 Activity，直到返回到桌面 (或者到这个栈开始时正在运行的 Activity)。当所有的 Activity从栈中移出了，这个栈就不存在了。</p>

<div class="figure" style="width:369px">
<img src="../../../images/fundamentals/diagram_multitasking.png" alt="" /> <p
class="img-caption"><strong>Figure 2.</strong> Two tasks: Task A is in the background, waiting
to be resumed, while Task B receives user interaction in the foreground.</p>
</div>
<div class="figure" style="width:178px">
  <img src="../../../images/fundamentals/diagram_multiple_instances.png" alt="" /> <p
class="img-caption"><strong>Figure 3.</strong> A single activity is instantiated multiple times.</p>
</div>

<p>A task is a cohesive unit that can move to the "background" when users begin a new task or go
to the Home screen, via the HOME key. While in the background, all the activities in the task are
stopped, but the back stack for the task remains intact&mdash;the task has simply lost focus while
another task takes place, as shown in figure 2. A task can then return to the "foreground" so users
can pick up where they left off. Suppose, for example, that the current task (Task A) has three
activities in its stack&mdash;two under the current activity. The user presses the HOME key, then
starts a new application from the application launcher. When the Home screen appears, Task A goes
into the background. When the new application starts, the system starts a task for that application
(Task B) with its own stack of activities. After interacting with
that application, the user returns Home again and selects the application that originally
started Task A. Now, Task A comes to the
foreground&mdash;all three activities in its stack are intact and the activity at the top of the
stack resumes. At
this point, the user can also switch back to Task B by going Home and selecting the application icon
that started that task (or by touching and holding the HOME key to reveal recent tasks and selecting
one). This is an example of multitasking on Android.</p>
<p>一个 Task是一个聚合单元，当用户开启一个新的task，或者通过HOME键回到桌面，这个task就移动到后台。这时，task中的所有activity都被停止了，但是back stack还保存着task--只是失去了焦点。（一堆图片说明就不翻译了）</p>

<p class="note"><strong>Note:</strong> Multiple tasks can be held in the background at once.
However, if the user is running many background tasks at the same time, the system might begin
destroying background activities in order to recover memory, causing the activity states to be lost.
See the following section about <a href="#ActivityState">Activity state</a>.</p>
<p class="note"><strong>Note:</strong> 如果系统资源紧缺，就会引起activity状态消失，更多请看<a href="#ActivityState">Activity state</a>.</p>

<p>Because the activities in the back stack are never rearranged, if your application allows
users to start a particular activity from more than one activity, a new instance of
that activity is created and popped onto the stack (rather than bringing any previous instance of
the activity to the top). As such, one activity in your application might be instantiated multiple
times (even from different tasks), as shown in figure 3. As such, if the user navigates backward
using the BACK key, each instance of the activity is revealed in the order they were opened (each
with their own UI state). However, you can modify this behavior if you do not want an activity to be
instantiated more than once. How to do so is discussed in the later section about <a
href="#ManagingTasks">Managing Tasks</a>.</p>
<p>因为 back stack中的 activity不会被重置，如果你的应用允许你启动一个特定的 activity多次，创建一个新的 activity的实例，并且推入栈顶。所以在这种情况下，如果用户使用 BACK键导航，可能会多次看到同一个 activity。</p>


<p>To summarize the default behavior for activities and tasks:</p>
<p>总结activities和tasks的默认行为:</p>

<ul>
  <li>When Activity A starts Activity B, Activity A is stopped, but the system retains its state
(such as scroll position and text entered into forms).
If the user presses the BACK key while in Activity B, Activity A resumes with its state
restored.
<p>当 Activity A 启动 Activity B, Activity A停止了，但是系统会保存他的状态 (例如滚动条的位置以及输入的文本信息 )。当用户在Activity B中按BACK键， Activity A将继续他之间的状态。</p></li>
  <li>When the user leaves a task by pressing the HOME key, the current activity is stopped and
its task goes into the background. The system retains the state of every activity in the task. If
the user later resumes the task by selecting the launcher icon that began the task, the task comes
to the foreground and resumes the activity at the top of the stack.
<p>当用户通过按 HOME键的方式离开一个 task，当前的 Activity停止，并且这个 task转到后台。系统将保持这个 task的所有的 activity的状态。如果稍后再继续这个 task,这个 task将回到前台，并且继续之间最栈顶的 Activity。 </p></li>
  <li>If the user presses the BACK key, the current activity is popped from the stack and
destroyed. The previous activity in the stack is resumed. When an activity is destroyed, the system
<em>does not</em> retain the activity's state.
<p>如果用户按 BACK键，当前 Activity弹出栈并被销毁。栈中之前的 Activity得以继续。当 Activity被销毁了，系统将不再保存其状态。</p></li>
  <li>Activities can be instantiated multiple times, even from other tasks.
  <p> Activity可以被实例化多次，甚至从其它的task中实例。</p></li>
</ul>


<h2 id="ActivityState">Saving Activity State 保存activity状态</h2>

<p>As discussed above, the system's default behavior preserves the state of an activity when it is
stopped. This way, when users navigate back to a previous activity, its user interface appears
the way they left it. However, you can&mdash;and <strong>should</strong>&mdash;proactively retain
the state of your activities using callback methods, in case the activity is destroyed and must
be recreated.</p>
<p>正如前面讨论的那样，当activity停止的时候，系统默认的行为会保存他的状态。这样的话，当导航到上一个Activity，他的接口会像他离开时的一样展现给用户。然而，你可以且应该在回调方法中主动保存你的状态，以避免万一你的Activity被销毁掉或者重新创建。</p>

<p>When the system stops one of your activities (such as when a new activity starts or the task
moves to the background), the system might destroy that activity completely if it needs to recover
system memory. When this happens, information about the activity state is lost. If this happens, the
system still
knows that the activity has a place in the back stack, but when the activity is brought to the
top of the stack the system must recreate it (rather than resume it). In order to
avoid losing the user's work, you should proactively retain it by implementing the <code><a href="../../../reference/android/app/Activity.html#onSaveInstanceState(android.os.Bundle)">onSaveInstanceState()</a></code> callback
methods in your activity.</p>
<p>当系统停止你的一个Activity，系统可能为了重新获得内存而完全销毁掉他。当这种情况发生了， activity的状态信息会丢失掉。但是，系统仍然知道这些activity在back stack有一个位置的，但是当 activity到栈顶的时候，系统会重新创建他，而不是resume他了。为了避免丢失用户的工作，你需要实现 onSaveInstanceState()主动保存你的 activity状态。</p>

<p>For more information about how to save your activity state, see the <a
href="../../../guide/topics/fundamentals/activities.html#SavingActivityState">Activities</a>
document.</p>



<h2 id="ManagingTasks">Managing Tasks 管理task</h2>

<p>The way Android manages tasks and the back stack, as described above&mdash;by placing all
activities started in succession in the same task and in a "last in, first out" stack&mdash;works
great for most applications and you shouldn't have to worry about how your activities are associated
with tasks or how they exist in the back stack. However, you might decide that you want to interrupt
the normal behavior. Perhaps you want an activity in your application to begin a new task when it is
started (instead of being placed within the current task); or, when you start an activity, you want
to bring forward an existing instance of it (instead of creating a new
instance on top of the back stack); or, you want your back stack to be cleared of all
activities except for the root activity when the user leaves the task.</p>
<p>像前面描述的一样， Android管理task与back stack的方法是--将所有的打开的activity连续的放进同一个 task中，并且放到一个“后入，先出”的堆栈中--面对大多数的应用，你不必关心你的 activity是如何与 task关联的，不必关心你的 activity是如何存在于 back stack中的。然而你可能想打破这种常态的行为。也许你想要让你应用的 activity被启动的时候去开启一个新的 task(而不是将其放入当前的栈中 );或者，当你启动一个 activity的时候，你想将其转到一个已存在的他的实体中去 (而不是在 back stack 的栈顶创建一个新的实体 );或者，当你离开这个 task时，你想让你的 back stack栈中除根 activity的所有的 activity都被清理掉。</p>

<p>You can do these things and more, with attributes in the
<a href="../../../guide/topics/manifest/activity-element.html"><code>&lt;activity&gt;</code></a> manifest element and with flags in the intent that you pass to <code><a href="../../../reference/android/app/Activity.html#startActivity(android.content.Intent)">startActivity()</a></code>.</p>

<p>In this regard, the the principal <a
href="../../../guide/topics/manifest/activity-element.html"><code>&lt;activity&gt;</code></a>
attributes you can use are:</p>

<ul class="nolist">
  <li><a href="../../../guide/topics/manifest/activity-element.html#aff"><code>taskAffinity</code></a></li>
  <li><a href="../../../guide/topics/manifest/activity-element.html#lmode"><code>launchMode</code></a></li>
  <li><a href="../../../guide/topics/manifest/activity-element.html#reparent"><code>allowTaskReparenting</code></a></li>
  <li><a href="../../../guide/topics/manifest/activity-element.html#clear"><code>clearTaskOnLaunch</code></a></li>
  <li><a href="../../../guide/topics/manifest/activity-element.html#always"><code>alwaysRetainTaskState</code></a></li>
  <li><a href="../../../guide/topics/manifest/activity-element.html#finish"><code>finishOnTaskLaunch</code></a></li>
</ul>

<p>And the principal intent flags you can use are:</p>

<ul class="nolist">
  <li><code><a href="../../../reference/android/content/Intent.html#FLAG_ACTIVITY_NEW_TASK">FLAG_ACTIVITY_NEW_TASK</a></code></li>
  <li><code><a href="../../../reference/android/content/Intent.html#FLAG_ACTIVITY_CLEAR_TOP">FLAG_ACTIVITY_CLEAR_TOP</a></code></li>
  <li><code><a href="../../../reference/android/content/Intent.html#FLAG_ACTIVITY_SINGLE_TOP">FLAG_ACTIVITY_SINGLE_TOP</a></code></li>
</ul>

<p>In the following sections, you'll see how you can use these manifest attributes and intent
flags to define how activities are associated with tasks and how the behave in the back stack.</p>


<p class="caution"><strong>Caution:</strong> Most applications should not interrupt the default
behavior for activities and tasks. If you determine that it's necessary for your activity to modify
the default behaviors, use caution and be sure to test the usability of the activity during
launch and when navigating back to it from other activities and tasks with the BACK key. Be sure 
to test for navigation behaviors that might conflict with the user's expected behavior.</p>


<h3 id="TaskLaunchModes">Defining launch modes</h3>

<p>Launch modes allow you to define how a new instance of an activity is associated with the
current task. You can define different launch modes in two ways:</p>
<ul class="nolist">
  <li><a href="#ManifestForTasks">Using the manifest file</a>
    <p>When you declare an activity in your manifest file, you can specify how the activity
should associate with tasks when it starts.</li>
  <li><a href="#IntentFlagsForTasks">Using Intent flags</a>
    <p>When you call <code><a href="../../../reference/android/app/Activity.html#startActivity(android.content.Intent)">startActivity()</a></code>,
you can include a flag in the <code><a href="../../../reference/android/content/Intent.html">Intent</a></code> that declares how (or
whether) the new activity should associate with the current task.</p></li>
</ul>

<p>As such, if Activity A starts Activity B, Activity B can define in its manifest how it
should associate with the current task (if at all) and Activity A can also request how Activity
B should associate with current task. If both activities define how Activity B
should associate with a task, then Activity A's request (as defined in the intent) is honored
over Activity B's request (as defined in its manifest).</p>

<p class="note"><strong>Note:</strong> Some the launch modes available in the manifest
are not available as flags for an intent and, likewise, some launch modes available as flags
for an intent cannot be defined in the manifest.</p>


<h4 id="ManifestForTasks">Using the manifest file</h4>

<p>When declaring an activity in your manifest file, you can specify how the activity should
associate with a task using the <a
href="../../../guide/topics/manifest/activity-element.html"><code>&lt;activity&gt;</code></a>
element's <a href="../../../guide/topics/manifest/activity-element.html#lmode"><code>launchMode</code></a> attribute.</p>

<p>The <a href="../../../guide/topics/manifest/activity-element.html#lmode"><code>launchMode</code></a> attribute specifies an instruction on how the activity should be launched into a
task. There are four different launch modes you can assign to the
<code><a href="../../../guide/topics/manifest/activity-element.html#lmode">launchMode</a></code>
attribute:</p>

<dl>
<dt><code>"standard"</code> (the default mode)</dt>
  <dd>Default. The system creates a new instance of the activity in the task from
which it was started and routes the intent to it. The activity can be instantiated multiple times,
each instance can belong to different tasks, and one task can have multiple instances.</dd>
<dt><code>"singleTop"</code></dt>
  <dd>If an instance of the activity already exists at the top of the current task, the system
routes the intent to that instance through a call to its <code><a href="../../../reference/android/app/Activity.html#onNewIntent(android.content.Intent)">onNewIntent()</a></code> method, rather than creating a new instance of the
activity. The activity can be instantiated multiple times, each instance can
belong to different tasks, and one task can have multiple instances (but only if the the
activity at the top of the back stack is <em>not</em> an existing instance of the activity).
  <p>For example, suppose a task's back stack consists of root activity A with activities B, C,
and D on top (the stack is A-B-C-D; D is on top). An intent arrives for an activity of type D.
If D has the default <code>"standard"</code> launch mode, a new instance of the class is launched and the
stack becomes A-B-C-D-D. However, if D's launch mode is <code>"singleTop"</code>, the existing instance
of D receives the intent through <code><a href="../../../reference/android/app/Activity.html#onNewIntent(android.content.Intent)">onNewIntent()</a></code>, because it's at the top of the stack&mdash;the
stack remains A-B-C-D. However, if an intent arrives for an activity of type B, then a new
instance of B is added to the stack, even if its launch mode is <code>"singleTop"</code>.</p>
  <p class="note"><strong>Note:</strong> When a new instance of an activity is created,
the user can press the BACK key to return to the previous activity. But when an existing instance of
an activity handles a new intent, the user cannot press the BACK key to return to the state of
the activity before the new intent arrived in <code><a href="../../../reference/android/app/Activity.html#onNewIntent(android.content.Intent)">onNewIntent()</a></code>.</p>
</dd>

<dt><code>"singleTask"</code></dt>
  <dd>The system creates a new task and instantiates the activity at the root of the new task.
However, if an instance of the activity already exists in a separate task, the system routes the
intent to the existing instance through a call to its <code><a href="../../../reference/android/app/Activity.html#onNewIntent(android.content.Intent)">onNewIntent()</a></code> method, rather than creating a new instance. Only
one instance of the activity can exist at a time.
  <p class="note"><strong>Note:</strong> Although the activity starts in a new task, the
BACK key still returns the user to the previous activity.</p></dd>
<dt><code>"singleInstance"</code>.</dt>
  <dd>Same as <code>"singleTask"</code>, except that the system doesn't launch any other activities into
the task holding the instance. The activity is always the single and only member of its task;
any activities started by this one open in a separate task.</dd>
</dl>


<p>As another example, the Android Browser application declares that the web browser activity should
always open in its own task&mdash;by specifying the <code>singleTask</code> launch mode in the <a
href="../../../guide/topics/manifest/activity-element.html"><code>&lt;activity&gt;</code></a> element.
This means that if your application issues an
intent to open the Android Browser, its activity is <em>not</em> placed in the same
task as your application. Instead, either a new task starts for the Browser or, if the Browser
already has a task running in the background, that task is brought forward to handle the new
intent.</p>

<p>Regardless of whether an activity starts in a new task or in the same task as the activity that
started it, the BACK key always takes the user to the previous activity. However, if you
start an activity from your task (Task A) that specifies the <code>singleTask</code> launch mode, then
that activity might have an instance in the background that belongs to a task with its own back
stack (Task B). In this
case, when Task B is brought forward to handle a new intent, the BACK key first navigates
backward through the activities in Task B before returning to
the top-most activity in Task A. Figure 4 visualizes this type of scenario.</p>

<img src="../../../images/fundamentals/diagram_backstack_singletask_multiactivity.png" alt="" />
<p class="img-caption"><strong>Figure 4.</strong> A representation of how an activity with
launch mode "singleTask" is added to the back stack. If the activity is already a part of a
background task with its own back stack (Task B), then the entire back stack also comes
forward, on top of the current task (Task A).</p>

<p>For more information about using launch modes in the manifest file, see the
<code><a href="../../../guide/topics/manifest/activity-element.html">&lt;activity&gt;</a></code>
element documentation, where the <code>launchMode</code> attribute and the accepted values are
discussed more.</p>

<p class="note"><strong>Note:</strong> The behaviors that you specify for your activity with the <a
href="../../../guide/topics/manifest/activity-element.html#lmode"><code>launchMode</code></a> attribute
can be overridden by flags included with the intent that start your activity, as discussed in the
next section.</p>



<h4 id="#IntentFlagsForTasks">Using Intent flags</h4>

<p>When starting an activity, you can modify the default association of an activity to its task
by including flags in the intent that you deliver to <code><a href="../../../reference/android/app/Activity.html#startActivity(android.content.Intent)">startActivity()</a></code>. The flags you can use to modify the
default behavior are:</p>

<p>
  <dt><code><a href="../../../reference/android/content/Intent.html#FLAG_ACTIVITY_NEW_TASK">FLAG_ACTIVITY_NEW_TASK</a></code></dt>
    <dd>Start the activity in a new task. If a task is already running for the activity you are now
starting, that task is brought to the foreground with its last state restored and the activity
receives the new intent in <code><a href="../../../reference/android/app/Activity.html#onNewIntent(android.content.Intent)">onNewIntent()</a></code>. 
    <p>This produces the same behavior as the <code>"singleTask"</code> <a
href="../../../guide/topics/manifest/activity-element.html#lmode"><code>launchMode</code></a> value,
discussed in the previous section.</p></dd>
  <dt><code><a href="../../../reference/android/content/Intent.html#FLAG_ACTIVITY_SINGLE_TOP">FLAG_ACTIVITY_SINGLE_TOP</a></code></dt>
    <dd>If the activity being started is the current activity (at the top of the back stack), then
the existing instance receives a call to <code><a href="../../../reference/android/app/Activity.html#onNewIntent(android.content.Intent)">onNewIntent()</a></code>,
instead of creating a new instance of the activity.
    <p>This produces the same behavior as the <code>"singleTop"</code> <a
href="../../../guide/topics/manifest/activity-element.html#lmode"><code>launchMode</code></a> value,
discussed in the previous section.</p></dd>
  <dt><code><a href="../../../reference/android/content/Intent.html#FLAG_ACTIVITY_CLEAR_TOP">FLAG_ACTIVITY_CLEAR_TOP</a></code></dt>
    <dd>If the activity being started is already running in the current task, then instead
of launching a new instance of that activity, all of the other activities on top of it are
destroyed and this intent is delivered to the resumed instance of the activity (now on top),
through <code><a href="../../../reference/android/app/Activity.html#onNewIntent(android.content.Intent)">onNewIntent()</a></code>).
    <p>There is no value for the <a
href="../../../guide/topics/manifest/activity-element.html#lmode"><code>launchMode</code></a>
attribute that produces this behavior.</p>
    <p><code>FLAG_ACTIVITY_CLEAR_TOP</code> is most often used in conjunction with <code>FLAG_ACTIVITY_NEW_TASK</code>.  When used together, these flags are a way of locating an existing activity
in another task and putting it in a position where it can respond to the intent. </p>
    <p class="note"><strong>Note:</strong> If the launch mode of the designated activity is <code>"standard"</code>, it too is removed from the stack and a new instance is launched in its place to handle
the incoming intent.  That's because a new instance is always created for a new intent when the
launch mode is <code>"standard"</code>. </p>
</dd>
</dl>





<h3 id="Affinities">Handling affinities</h3>

<p>The <em>affinity</em> indicates which task an activity prefers to belong to. By default, all the
activities from the same application have an affinity for each other. So, by default, all
activities in the same application prefer to be in the same task. However, you can modify
the default affinity for an activity. Activities defined in
different applications can share an affinity, or activities defined in the same application can be
assigned different task affinities.</p>

<p>You can modify the affinity for any given activity with the <a
href="../../../guide/topics/manifest/activity-element.html#aff"><code>taskAffinity</code></a> attribute
of the <a href="../../../guide/topics/manifest/activity-element.html"><code>&lt;activity&gt;</code></a>
element.</p>

<p>The <a
href="../../../guide/topics/manifest/activity-element.html#aff"><code>taskAffinity</code></a>
attribute takes a string value, which must be unique from the default package name
declared in the <a href="../../../guide/topics/manifest/manifest-element.html"><code>&lt;manifest&gt;</code></a> element, because the system uses that name to identify the default task
affinity for the application.</p>

<p>The affinity comes into play in two circumstances:</p>
<ul>
  <li>When the intent that launches an activity contains the <code><a href="../../../reference/android/content/Intent.html#FLAG_ACTIVITY_NEW_TASK">FLAG_ACTIVITY_NEW_TASK</a></code> flag.

<p>A new activity is, by default, launched into the task of the activity
that called <code><a href="../../../reference/android/app/Activity.html#startActivity(android.content.Intent)">startActivity()</a></code>. It's pushed onto the same
back stack as the caller.  However, if the intent passed to <code><a href="../../../reference/android/app/Activity.html#startActivity(android.content.Intent)">startActivity()</a></code> contains the <code><a href="../../../reference/android/content/Intent.html#FLAG_ACTIVITY_NEW_TASK">FLAG_ACTIVITY_NEW_TASK</a></code>
flag, the system looks for a different task to house the new activity. Often, it's a new task. 
However, it doesn't have to be.  If there's already an existing task with the same affinity as the
new activity, the activity is launched into that task.  If not, it begins a new task.</p>

<p>If this flag causes an activity to begin a new task and the user presses the HOME key to leave
it, there must be some way for the user to navigate back to the task. Some entities (such as the
notification manager) always start activities in an external task, never as part of their own, so
they always put <code>FLAG_ACTIVITY_NEW_TASK</code> in the intents they pass to <code><a href="../../../reference/android/app/Activity.html#startActivity(android.content.Intent)">startActivity()</a></code>.  If you have an activity that can be invoked by
an external entity that might use this flag, take care that the user has a independent way to get
back to the task that's started, such as with a launcher icon (the root activity of the task
has a <code><a href="../../../reference/android/content/Intent.html#CATEGORY_LAUNCHER">CATEGORY_LAUNCHER</a></code> intent filter; see the <a
href="#Starting">Starting a task</a> section below).</p>
</li>

  <li>When an activity has its <a
href="../../../guide/topics/manifest/activity-element.html#reparent"><code>allowTaskReparenting</code></a> attribute set to <code>"true"</code>.
  <p>In this case, the activity can move from the task it starts to the task it has an affinity
for, when that task comes to the foreground.</p>
  <p>For example, suppose that an activity that reports weather conditions in selected cities is
defined as part of a travel application.  It has the same affinity as other activities in the same
application (the default application affinity) and it allows re-parenting with this attribute.
When one of your activities starts the weather reporter activity, it initially belongs to the same
task as your activity. However, when the travel application's task comes to the foreground, the
weather reporter activity is reassigned to that task and displayed within it.</p>
</li>
</ul>

<p class="note"><strong>Tip:</strong> If an <code>.apk</code> file contains more than one "application"
from the user's point of view, you probably want to use the <a
href="../../../guide/topics/manifest/activity-element.html#aff"><code>taskAffinity</code></a>
attribute to assign different affinities to the activities associated with each "application".</p>



<h3 id="Clearing">Clearing the back stack</h3>

<p>If the user leaves a task for a long time, the system clears the task of all activities except
the root activity.  When the user returns to the task again, only the root activity is restored.
The system behaves this way, because, after an extended amount of time, users likely have abandoned
what they were doing before and are returning to the task to begin something new. </p>

<p>There are some activity attributes that you can use to modify this behavior: </p>

<dl>
<dt><code><a
href="../../../guide/topics/manifest/activity-element.html#always">alwaysRetainTaskState</a></code>
</dt>
<dd>If this attribute is set to <code>"true"</code> in the root activity of a task,
the default behavior just described does not happen.
The task retains all activities in its stack even after a long period.</dd>

<dt><code><a
href="../../../guide/topics/manifest/activity-element.html#clear">clearTaskOnLaunch</a></code></dt>
<dd>If this attribute is set to <code>"true"</code> in the root activity of a task,
the stack is cleared down to the root activity whenever the user leaves the task
and returns to it.  In other words, it's the opposite of <a
href="../../../guide/topics/manifest/activity-element.html#always"><code>alwaysRetainTaskState</code></a>.  The user always returns to the task in its
initial state, even after a leaving the task for only a moment.</dd>

<dt><code><a
href="../../../guide/topics/manifest/activity-element.html#finish">finishOnTaskLaunch</a></code>
</dt>
<dd>This attribute is like <a
href="../../../guide/topics/manifest/activity-element.html#clear"><code>clearTaskOnLaunch</code></a>,
but it operates on a
single activity, not an entire task.  It can also cause any activity to go
away, including the root activity.  When it's set to <code>"true"</code>, the
activity remains part of the task only for the current session.  If the user
leaves and then returns to the task, it is no longer present.</dd>
</dl>




<h3 id="Starting">Starting a task</h3>

<p>You can set up an activity as the entry point for a task by giving it an intent filter with
<code>"android.intent.action.MAIN"</code> as the specified action and <code>"android.intent.category.LAUNCHER"</code> as the specified category. For example:</p>

<pre>
&lt;activity ... &gt;
    &lt;intent-filter ... &gt;
        &lt;action android:name="android.intent.action.MAIN" /&gt;
        &lt;category android:name="android.intent.category.LAUNCHER" /&gt;
    &lt;/intent-filter&gt;
    ...
&lt;/activity&gt;
</pre>

<p>An intent filter of this kind causes an icon and label for the
activity to be displayed in the application launcher, giving users a way to launch the activity and
to return to the task that it creates any time after it has been launched.
</p>

<p>This second ability is important: Users must be able to leave a task and then come back to it
later using this activity launcher.  For this reason, the two <a href="#LaunchModes">launch
modes</a> that mark activities as always initiating a task, <code>"singleTask"</code> and "<code>"singleInstance"</code>, should be used only when the activity has an <code><a href="../../../reference/android/content/Intent.html#ACTION_MAIN">ACTION_MAIN</a></code>
and a <code><a href="../../../reference/android/content/Intent.html#CATEGORY_LAUNCHER">CATEGORY_LAUNCHER</a></code>
filter. Imagine, for example, what could happen if the filter is missing: An intent launches a
<code>"singleTask"</code> activity, initiating a new task, and the user spends some time working in
that task.  The user then presses the HOME key. The task is now sent to the background and not
visible. Because it is not represented in the application launcher, the user has no way to return to
the task.
</p>

<p>For those cases where you don't want the user to be able to return to an activity, set the
  <code><a
href="../../../guide/topics/manifest/activity-element.html">&lt;activity&gt;</a></code> element's
<a href="../../../guide/topics/manifest/activity-element.html#finish"><code>finishOnTaskLaunch</code></a> to <code>"true"</code> (see <a
href="#Clearing">Clearing the stack</a>).</p>



<!--
<h2>Beginner's Path</h2>

<p>For more information about how to use intents to
activate other application components and publish the intents to which your components
respond, continue with the <b><a
href="../../../guide/topics/intents/intents-filters.html">Intents and Intent
Filters</a></b> document.</p>
-->

    </div>

  <a href="#top" style="float:right">&uarr; Go to top</a>
  
    <p><a href="activities.html">&larr; Back to Activities</a></p>
  
  </div>

<div id="footer">


  <div id="copyright">
    
  Except as noted, this content is licensed under <a
  href="http://www.apache.org/licenses/LICENSE-2.0">Apache 2.0</a>. 
  For details and restrictions, see the <a href="../../../license.html">
  Content License</a>.
  </div>
  <div id="build_info">
    
  Android 4.0&nbsp;r1 - 17 Oct 2011 18:17

  </div>

  <div id="footerlinks">
    
  <p>
    <a href="http://www.android.com/terms.html">Site Terms of Service</a> -
    <a href="http://www.android.com/privacy.html">Privacy Policy</a> -
    <a href="http://www.android.com/branding.html">Brand Guidelines</a>
  </p>
  </div>

</div> <!-- end footer -->

</div><!-- end doc-content -->

</div> <!-- end body-content --> 

<script type="text/javascript">
init(); /* initialize android-developer-docs.js */
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
var pageTracker = _gat._getTracker("UA-5831155-1");
pageTracker._trackPageview();
</script>

</body>
</html>



